#pragma once
extern "C"
{
#include <hidsdi.h>
#include <setupapi.h>
}
class UsbHid;
typedef UsbHid*(*HIDCREATE)(HDEVINFO,SP_DEVICE_INTERFACE_DATA*);

class UsbHid{
public:
	UsbHid	(void){device=INVALID_HANDLE_VALUE;thread=0;};
	UsbHid	(HDEVINFO,SP_DEVICE_INTERFACE_DATA*);
	virtual ~UsbHid	(void);

	uint	getReport		(void*,uint);
	void	sendReport		(void*,uint);

	static void		closeAll	(void);
	static uint		localTick	(void);
	static PTSTR	serialNumber(void);

protected:
	static	void	openAll		(HIDCREATE);
	virtual uint	threadEntry	(void);
	TCHAR	serialNum[MAX_PATH];

private:
	static UsbHid* head;

	static uint WINAPI	threadProc	(void*);

	HANDLE device,thread;
	UsbHid* link;
};